class MainAcademyController {

    def index = { redirect(action:show) }
    
    def show = {
    		/*println "-----Portal-----------------------"
    		println p.name
    		println p.description
    		println p.urlBase
    		println "-----------------------------------\n\n"*/
    		
    		/*println "------------All News---------------"
    		for(i in list) {
    			println "------------News---------------"
    			println i.title
    			println "posted By " + i.author
    			println i.description
    			println i.date
    			println "------------/News--------------\n"
    		}
    		println "-----------------------------------\n\n"
*/    		println params
			def percomp = Portal.findByName("Percomp")
			def academy = Portal.findByName("Academy")
			def percompNews=[]
    		def academyNews=[]
    		
    		///def events = Event.findAll("")
			if(percomp)
				percompNews = News.findAll("from News as n where portal=:portal order by n.date desc",
    				[portal:percomp])
    		if(academy)
    			academyNews = News.findAll("from News as n where portal=:portal order by n.date desc",
    				[portal:academy])
    		
    		//Date date = academyNews.get(0).date
    		
    		//println date.
    		
    		if(!percompNews) percompNews=[]
    		if(!academyNews) academyNews=[]

    		render(view:'mainAcademy', model:['percompNews':percompNews, 'academyNews':academyNews])
    }
    // Academy news
    def showRightColumn = {
    		def academy = Portal.findByName("Academy")
    		def academyNews=[]
    		if(academy)
    			academyNews = News.findAll("from News as n where portal=:portal order by n.date desc",
    				[portal:academy], params)
    		if(!academyNews) academyNews=[]		
    		return ['academyNews':academyNews]
    }
    
    // Percomp News
    def showLeftColumn = {
    		def percomp = Portal.findByName("Percomp")
    		def percompNews=[]
    		if(percomp)
				percompNews = News.findAll("from News as n where portal=:portal order by n.date desc",
    				[portal:percomp], params)
    		if(!percompNews) percompNews=[]
    		return ['percompNews':percompNews]
    }
    
    def showEvent = {
    		
    }
    
    def showStudent = {
    		
    }
    
    def showCourses = {
    		
    }
}
